//pages/start/index.js
var app = getApp();

Page({
  //页面初始数据
  data: {
    remind: '加载中',
    userInfo: {},
    angle: 0,
  },
  //生命周期-监听页面加载
  onLoad: function() {

  },
  //监听页面初次渲染完成
  onReady: function() {
    var that = this;
    setTimeout(function() {
      that.setData({
        remind: ''
      })
    }, 1000);
    wx.onAccelerometerChange(function(res) {
      console.log(res)
      var angle = -(res.x * 30).toFixed(1);
      if (angle > 14) {
        angle = 14;
      } else if (angle < -14) {
        angle = -14;
      }
      if (that.data.angle !== angle) {
        that.setData({
          angle: angle
        });
      }
    });
  },
  //监听页面显示
  onShow: function() {
    let that = this;
    let token = wx.getStorageSync('token')
    if (!token) {
      wx.navigateTo({
        url: "/pages/authorize/index"
      })
    } else {
      that.setData({
        userInfo: token
      })
    }
  },
  //监听页面隐藏
  onHide: function() {

  },
  //监听页面卸载
  onUnload: function() {

  },
  //监听用户下拉
  onReachBottom: function() {

  },
  //页面上拉触底事件的处理函数
  onReachButtom: function() {

  },
  //用户点击右上角分享
  onShareAppMessage: function() {

  },
})